package org.lds.ers.client.widgets;

import org.lds.ers.client.MyInfo;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

/*
 * 登入後的主畫面
 */
public class MainForm extends VerticalPanel {
	private static MainForm singleton;
	public static MainForm getInstance()
	{
		if (singleton==null)
			singleton = new MainForm();
		
		return singleton;
	}
	
	private MainForm(){
		this.setWidth("100%");
		this.setHeight("100%");
		
		//1. Add Banner
		final HorizontalPanel pnlBanner = new HorizontalPanel();
		this.add(pnlBanner);
		this.setCellHeight(pnlBanner, "100px");
		
		Image img = new Image();
		img.setUrl("http://www.lds.org/images/logo_english.gif");
		pnlBanner.add(img);
		HTML htm = new HTML();
		htm.setWidth("100%");
		htm.setHTML("<span style='font-size:20px;padding-left:20px;top:20px' >新竹支聯會 ERSC 系統</span>");
		htm.setStyleName("menubar");
		pnlBanner.add(htm);
		pnlBanner.setCellWidth(htm, "400px");
		
		Label lbl = new Label(MyInfo.get().getNickname() + "(" + MyInfo.get().getEmailAddress() + ")");
		HTML htm2 = new HTML();
		htm2.setHTML("&nbsp;&nbsp;|&nbsp;&nbsp;");
		
		Anchor link = new Anchor("Logout");
		link.setHref(MyInfo.get().getLogoutUrl());
		pnlBanner.add(htm2);
		pnlBanner.add(lbl);
		pnlBanner.add(htm2);
		pnlBanner.add(link);
		
		//2. Add Horizontal Panel
		final HorizontalPanel pnlHorizontal = new HorizontalPanel();
		this.add(pnlHorizontal);
		
		//3. Add Left Menu
		pnlHorizontal.add(MainMenu.getInstance());
		
		//4. Add Content Area
		pnlHorizontal.add(ContentArea.getInstance());
		
	}
}
